package com.blog.wl2023.entity;

import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Date;

/**
 * @author wule
 * @data 2023年08月15日22时
 * @description
 */
@Entity
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "user")
@Data
public class User extends BaseEntity {

	@Column(name = "email")
	private String email;

	@Column(name = "password")
	private String password;

	@Column(name = "username")
	private String username;

	@Column(name = "code")
	private String code;

	@Column(name = "status")
	private String status;

	@Column(name = "image_url")
	private String imageUrl;

	@Column(name = "gender")
	private String gender;

	@Column(name = "introduction")
	private String introduction;

	@Column(name = "create_time")
	private Date createTime;

	/**
	* 添加一个不属于数据库的属性
	**/
	@Transient
	private TokenInfo tokenInfo;

	public User(String uuid,String username, String imageUrl) {
		this.setUuid(uuid);
		this.username = username;
		this.imageUrl = imageUrl;
	}

	public User(String uuid,String email,String password, String username, String imageUrl, String gender, String introduction,Date createTime,String status) {
		this.setUuid(uuid);
		this.email = email;
		this.password = password;
		this.username = username;
		this.imageUrl = imageUrl;
		this.gender = gender;
		this.introduction = introduction;
		this.createTime = createTime;
		this.status = status;
	}
	public User(String uuid,String email,String username, String imageUrl, String gender, String introduction,Date createTime) {
		this.setUuid(uuid);
		this.email = email;
		this.username = username;
		this.imageUrl = imageUrl;
		this.gender = gender;
		this.introduction = introduction;
		this.createTime = createTime;
	}

	public User(String uuid) {
		this.setUuid(uuid);
	}

	@PrePersist
	public void prePersist() {
		this.createTime = new Date();
	}
}
